<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/WEB-INF/template/globalTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core">


    <ui:define name="title">#{msg['application.titre.utilisateur.session']}</ui:define>


    <ui:define name="ariane">
        <h:commandLink action="/faces/index.xhtml"  
                       value="#{msg['application.titre.accueil']}"/>
        >
        #{msg['application.titre.utilisateur.session']}
    </ui:define>


    <ui:define name="content">

        <h:panelGroup styleClass="titre">Gestion des sessions</h:panelGroup>
        La liste ci-dessous répertorie l'ensemble des sessions pour lesquelles vous
        avez été désigné en tant qu'instructeur.<br/><br/>

        <p:dataTable var="uneSession" value="#{userSeanceBean.listSession}" widgetVar="sessionTable" emptyMessage="#{msg['application.emptyMessage']}">  

            <p:column headerText="Formation" >  
                <h:outputText value="#{uneSession.formation.domaine.libelle} - #{uneSession.formation.libelle}" />  
            </p:column> 

            <p:column headerText="Inscriptions" >
                <h:panelGroup style="cursor:default">
                    <h:outputText value=" #{uneSession.nbPlaceMini} "
                                  id="outputMini"/>
                    <p:tooltip for="outputMini"
                               value="Minimum d'inscriptions autorisées"
                               showEffect="slide"
                               hideEffect="fade"/>
                    /
                    <h:outputText value=" #{userSeanceBean.nbInscrit(uneSession)} "
                                  id="outputNb"
                                  style="font-weight:bold"/>
                    <p:tooltip for="outputNb"
                               showEffect="slide"
                               hideEffect="fade">
                        <h:panelGroup rendered="#{userSeanceBean.listInscriptionValidees(uneSession).size()!=0}">
                            <h:outputText value="Liste des inscriptions validées :"
                                          style="font-weight:bold"/>
                            <p:dataTable value="#{userSeanceBean.listInscriptionValidees(uneSession)}"
                                         var="inscription"
                                         style="margin:5px 0">
                                <p:column headerText="Personne">
                                    <h:outputText value="#{inscription.personnel}" />
                                </p:column>
                                <p:column headerText="Etat">
                                    <h:outputText value="#{inscription.etat.libelle}" />
                                </p:column>
                            </p:dataTable>
                        </h:panelGroup>
                        <h:panelGroup rendered="#{userSeanceBean.listInscriptionNonValidees(uneSession).size()!=0}">
                            <h:outputText value="Liste des inscriptions non validées :"
                                          style="font-weight:bold"/>
                            <p:dataTable value="#{userSeanceBean.listInscriptionNonValidees(uneSession)}"
                                         var="inscription"
                                         style="margin:5px 0">
                                <p:column headerText="Personne">
                                    <h:outputText value="#{inscription.personnel}" />
                                </p:column>
                                <p:column headerText="Etat">
                                    <h:outputText value="#{inscription.etat.libelle}" />
                                </p:column>
                            </p:dataTable>
                        </h:panelGroup>
                        <h:panelGroup rendered="#{userSeanceBean.listInscriptionValidees(uneSession).size()==0 and 
                                                  userSeanceBean.listInscriptionNonValidees(uneSession).size()==0}">
                            <h:outputText value="Aucune inscription" style="font-weight:bold"/>
                        </h:panelGroup>
                    </p:tooltip>
                    /
                    <h:outputText value=" #{uneSession.nbPlaceMax} "
                                  id="outputMaxi"/>
                    <p:tooltip for="outputMaxi"
                               value="Maximum d'inscriptions autorisées"
                               showEffect="slide"
                               hideEffect="fade"/>
                </h:panelGroup>
            </p:column>

            <p:column headerText="Période" >  
                <h:outputText value="#{uneSession.dateDebut}">
                    <f:convertDateTime pattern="dd/MM/yy"/>
                </h:outputText>
                -
                <h:outputText value="#{uneSession.dateFin}" >
                    <f:convertDateTime pattern="dd/MM/yy"/>
                </h:outputText>
            </p:column>

            <p:column headerText="Etat" >
                <h:outputText value="#{uneSession.etat.libelle}" />
            </p:column>

            <p:column headerText="Actions" >
                <p:commandLink value="Verrouiller "   
                               action="#{userSeanceBean.verrouiller(uneSession)}"
                               rendered="#{userSeanceBean.canVerrouiller(uneSession)}"
                               update="globalForm:confirm"/>
                <p:commandLink id="downloadButton"
                               value="Imprimer "  
                               ajax="false"
                               update="messages"
                               rendered="#{userSeanceBean.canEmarger(uneSession)}">  
                    <p:fileDownload value="#{userSeanceBean.imprimer(uneSession)}" />  
                </p:commandLink>
                <p:commandLink value="Emarger "  
                               action="#{userSeanceBean.emargement(uneSession)}"
                               rendered="#{userSeanceBean.canEmarger(uneSession)}"/>
            </p:column>

        </p:dataTable>

    </ui:define>


</ui:composition>
